import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86183
 * Date: 2022-11-18
 * Time: 15:37
 */
class Student {
    String ID;
    String name;

    public Student(String ID, String name) {
        this.ID = ID;
        this.name = name;
    }

    @Override
    public String toString() {
        return  name ;
    }
}
public class Test1 {
    public static void main(String[] args) {
        TreeMap<String,Student> treeMap = new TreeMap<>(new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                return o2.compareTo(o1);
            }
        });
        treeMap.put("1",new Student("1","武松"));
        treeMap.put("3",new Student("3","大飞"));
        treeMap.put("4",new Student("4","白糖"));
        treeMap.put("2",new Student("2","小青"));
        treeMap.put("5",new Student("5","明月"));
        System.out.println(treeMap);
        Set<String> stringSet =  treeMap.keySet();
        System.out.println(stringSet);
        System.out.println(treeMap.get("5"));
        for (Map.Entry<String,Student> x :treeMap.entrySet()) {
            System.out.println(x.getKey()+ "-->"+ x.getValue());
        }
        Iterator<String> it = stringSet.iterator();
        while (it.hasNext()){
            String key = it.next();
            Student value = treeMap.get(key);
            System.out.println(key +":" + value);
        }

    }
}
